<?php

class OptionsCacheController extends Controller {
    var $name = 'OptionsCache';
    var $uses = array('Options');
    var $components = array('options');
    
    function index() {
        $this->action = 'options_cache';
        $this->options_cache();
    }
    
    function options_cache($status = null) {
        if (!empty($this->data)) {
            if (!empty($this->data['Options']['using_cache']) && $this->data['Options']['using_cache'] == 'on') {
                $timeout = (int)$this->data['Options']['cache_timeout'];
                $using_cache = 'true';
            } else {
                $timeout = CACHE_TIMEOUT;
                $using_cache = 'false';
            }
            if (empty($timeout)) {
                $timeout = 600;
            }
            update_cache_config($timeout, $using_cache);
            $this->redirect('/options_cache/options_cache/update_done');
        }
        if ($status == 'update_done') {
            $this->header_notice = __('Options saved.');
        }
        if (CACHE) {
            $this->data['Options']['using_cache'] = 'on';
        } else {
            $this->data['Options']['using_cache'] = '';
        }
        $this->data['Options']['cache_timeout'] = CACHE_TIMEOUT;
    }
}

?>
